Indexing Basics
In this article you will get a high-level overview of what indexing in Ucommerce means, how it works, and important information you need to be aware of when working with the platform.
What an Index is in Ucommerce
You are probably already aware of what an Index are as they are used in many different applications and tools in modern applications. Indexes are not one specific thing, but can be created in many ways and take many different forms. There's a lot of tools that help facilitate an Index. Common for all usages of indexes is they help looking up data faster. For example in SQL server. Common practice is to form indexes that help your queries run faster. It comes with the downside that writing data becomes slower as you both have to store the data itself as well as update whatever index you have. However in commerce it is essential to achieve the best possible performance for your visitors and customers using the webshop you are building.
In Ucommerce, we also create indexes that help serve data faster. So the act of Indexing your data in Ucommerce becomes the process of which you take your master data and transform it to a read-fast format.
SQL Server is the Master Storage
Every installation of Ucommerce comes with a SQL Server sitting somewhere. The SQL server is considered the main storage. This is where all the data created, deleted and modified will go. This is both for imported data as well as data edited through the back office. The database is not optimized for reading. So all master data relevant for presenting for your visitors will be indexed in a way that makes it faster to read. Indexes can be deleted without any fatal consequenses as they can just be regenerated based on the master data. This process may take a while depending on the amount of data you have.
How many indexes are created
Out of the box there will be generated an index per catalog item type e.g Stores, Catalogs, Categories, Products, and price groups. On top of that each index will be generated once per language, which means if you have 1 language you will end up with 5 indexes, whereas if you have 3 languages, 15 indexes will be generated.
On top of this, you can also specify your own index by implementing an index definition
What is Included in the Index
All the catalog data in Ucommerce will be indexed across multiple indexes as stated above. It includes the built-in properties for each item type.
This includes references to associated objects like products for a category or categories for a product. All references are stored as guids in the index (equivalent of foreign keys in SQL server).
Prices for products
Unit prices for products are stored as seperate fields where the name of the pricegroup acts as the key. They are mapped as a Dictionary in the product model.
So per default no user defined fields from definition data is available out of the box. You can specify your own fields by implementing an index definition
Index providers
The new APIs of Ucommerce are index / search engine agnostic which means that all the APIs provided by the Ucommerce class libraries are not tied to any given technology. The advantage of this is that Ucommerce (or you, or any other web agency) will be able to provide their own implementation of the Index providers. It means that you can chose the right technology for the right project. It also means that you don't have to change your codebase regardless of what index provider you are using. The only change needed is configuration.
In Ucommerce 9.0 through 9.3.1 Ucommerce ships with Lucene as an Index provider Out of the box. In 9.4 Elastic Search will be provided as an alternative. You can read about each supported index provider in this section for more relevant information.